<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
String path = request.getContextPath();
request.setCharacterEncoding("UTF-8");
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<base href="<%=basePath%>">
<title>合作伙伴渠道分类</title>

<jsp:include page="/WEB-INF/jsp/common/common.jsp"></jsp:include>
<link rel="stylesheet" href="<%=path%>/css/zTreeStyle/zTreeStyle.css">
<script type="text/javascript" src="<%=path%>/js/jquery.ztree.core-3.5.js"></script>
<script type="text/javascript" src="<%=path%>/js/jquery.ztree.excheck-3.5.js"></script>
<script src="<%=path%>/js/jquery.divbox.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
	history.forward();
	$(document).ready(function() {
		isReadyIframe();
		queryChannelInfo(1);
	});
	function isReadyIframe() {
		var iframe = $(window.parent.document).find("#iframe").length;
		if (iframe == 0) {
			window.location.href = "<%=basePath%>index.jsp";
		}
	}

	//点击“查询”
	function queryChannelInfo(pageIndex) {
		var channelName = $("#channelName").val();
		var channelCode = $.trim($("#channelCode").val());
		var businessChannelType = $("#businessChannelType").val();
		$.openLoading();
		//按照条件执行查询操作
		$.ajax({
			url: "<%=path%>/channelClassification/queryByCriteria1?" + new Date().getTime(),
			type: 'POST',
			async: true,
			data: {
				channelName: channelName,
				channelCode: channelCode,
				businessChannelType:businessChannelType,
				pageIndex: pageIndex
			},
			dataType: 'json',
			success: function(channelInfoPage) {
				$.closeLoading();
	
				if ($.validate(channelInfoPage)) return;
				if (null != channelInfoPage) {
					var buttonStr = "<a href='javascript:void(0)' onClick='viewChannelClassification(this);return false'>编辑</a>";
					var fieldNames = "CHANNEL_CODE,CHANNEL_NAME,DEPT_CNAME,CODE_NAME,TRANS_TYPE?[{'1':'界面出单'};{'2':'系统对接'}],TRANS_TYPE@TDH,DEPT_CODE@TDH,BUSINESS_CHANNEL_TYPE@TDH";
					var tableContent = creatTable1(fieldNames, channelInfoPage, null, buttonStr);
					var tableObj = $("#channelInfoTable");
					tableObj.find("tbody").remove();
					tableObj.append(tableContent);
		
					var strPage = creatChannelPage(pageIndex, 6, channelInfoPage.maxPage, "1");
					var pageDIV = $("#channelInfoPageDIV");
					pageDIV[0].innerHTML = "";
					pageDIV.append(strPage);
							
				}
			}
		});
	}
	
	//点击“编辑”
	function viewChannelClassification(channelClassification) {
		var tempTr = $(channelClassification).parent().parent()[0];
		var channelCode = tempTr.childNodes[0].innerHTML;
		var channelName = tempTr.childNodes[1].innerHTML;
		var channelClassification = tempTr.childNodes[7].innerHTML;
		$('#channelCodeInput').val(channelCode);
		$('#channelNameInput').val(channelName);
		$('#channelClassification').val(channelClassification);
		$("#editChannelClassificationDiv").OpenDiv();
	}
	
	//保存编辑内容
	function saveOrUpdateClassification() {
		var channelCode = $('#channelCodeInput').val();
		var businessChannelType = $('#channelClassification').val();
		//请求参数
		var params = {
			channelCode: channelCode,
			businessChannelType: businessChannelType
		};
		$.ajax({
			url: "<%=path%>/channelClassification/saveOrUpdateClassification",
			type: 'POST',
			async: true,
			data: params,
			dataType: 'json',
			success: function(obj) {
				$.closeLoading();
				if ($.validate(obj)) return;
				closeSaveOrUpdateDiv();
				queryChannelInfo(1);
			},
			error: function (jqXHR, textStatus, errorThrown) {
				$.message("error","保存失败,请联系管理员!");
			}
		});
	}

	
	//点击维护合作伙伴渠道分类
	function classificationInfo(){
		window.location.href='<%=basePath%>channelClassification/classificationInfo?' + new Date().getTime();
	}
	//导出合作伙伴渠道分类表
	function exportChannelClassification(){
		$("#downloadClassification").attr("action","<%=path%>/channelClassification/downloadClassification");
		$("#downloadClassification").submit();
	}
	//关闭弹出层,清空已查询的数据
	function closeSaveOrUpdateDiv() {
		$("#editChannelClassificationDiv").CloseDiv();
		reset();
	}
	//重置
	function reset(){
		$('#channelCode').val("");
		$('#channelName').val("");
		$('#businessChannelType').val("");
	}
</script>
</head>
<body>
	<div class="current">
		<table class="current_table_1">
			<tbody>
				<tr class="f2">
					<td><img src="./images/current_1.jpg"></td>
					<td class="current_table_1_td">
						<img src="images/current_1.png">&nbsp;您现在的位置：&nbsp;
						<span style=" color:#136bab; ">新意健险产品管理
							<span style="padding:0 5px; font-weight:bold; line-height:28px;">&gt;</span>合作伙伴渠道分类
						</span>
					</td>
					<td><img src="./images/current_3.jpg"></td>
				</tr>
			</tbody>
		</table>
	</div>

	<table border="1" id="channelTable" class="table_02" style="height:40%">
		<tr>
			<td>
			<form method="post" id="downloadClassification">
				<table class="search_table">
					<tr>
						<td width="20%" height="30">合作伙伴代码：
							<input  id="channelCode"  name = "channelCode" type="text" class="input_text" maxlength="30" >
						</td>
						<td width="20%" height="30">合作伙伴名称：
							<input id="channelName"  name = "channelName" type="text" class="input_text" maxlength="30" >
						</td>
						<td width="20%" height="30">合作伙伴渠道分类：
							<select id="businessChannelType"  name ="businessChannelType" class="select_1" style="visibility: visible;">
								<option value="" selected >--------请选择--------</option>
								<option value="未配置">未配置</option>
								<c:forEach var="channelClassificationList" items="${channelClassification}">
				            		<option value="${channelClassificationList.code}" title="${channelClassificationList.codeName}">${channelClassificationList.codeName}</option>
				        		</c:forEach>
							</select>
						</td>
						<td style="text-align: center;" colspan="5" width="40%" height="30">
							<input type="button" class="input_button_1" id="searchBtn" value="查询" onClick="queryChannelInfo(1);" />
							<input type="button" class="input_button_1" id="searchBtn" value="重置" onClick="reset()" />
						</td>
						<!--</table>
 							<table>-->
					</tr>
					<tr>
						<td width="20%" height=30 nowrap="nowrap">
							<input type="button" value="维护合作伙伴渠道分类"  onClick ="classificationInfo()"/>
							<input type="button" value="导出合作伙伴渠道分类表" onclick = "exportChannelClassification()"/>
						</td>
					</tr>
				</table>
				</form>
			</td>
		</tr>
		<tr>
			<td valign="top">
				<div id="channelInfoDIV" style="width:98%;margin:5px">
					<table class="table_02" id="channelInfoTable">
						<thead>
							<tr>
								<th style="width:10%">合作伙伴代码</th>
								<th style="width:25%">合作伙伴名称</th>
								<th style="width:25%">所属机构</th>
								<th style="width:10%">合作伙伴渠道分类</th>
								<th style="width:15%">合作方式</th>
								<th style="width:15%">操作</th>
							</tr>
						</thead>
					</table>
					<div id="channelInfoPageDIV" class="page"></div>
				</div>
			</td>
		</tr>
	</table>
	<%--添加或修改Classification相关数据弹出层 --%>
	<div id="editChannelClassificationDiv"  style="display:none;overflow-y:auto; width:40%">
			<input type="hidden" id="row_num" name="row_num" value="0"/>
			<div class="table_title_div">
					<table class="table_title" style='width:100%;height: 20px;'>
						<tr>
						<td width="10%"></td>
						<td width="80%" id="interfaceName"></td>
						<td width="10%" align="right"><img src="/manager/images/closedown.gif" alt="关闭"  onclick="closeSaveOrUpdateDiv()"/></td>
						</tr>
					</table>
			</div>
			<!-- 修改id 名 -->
			<table class="table_02" id="addtempletTable" align="center">
				<tbody>
					<tr>
						<td>
							<table id="coverageTable"  class="content_table_1" style="height:120px;">
								<tbody>
									<tr>
					                  <td width="30%" style="text-align:right;border-right:0px;">合作伙伴代码：&nbsp;</td>
					                  <td width="70%" style="text-align:left"><input type="text" id="channelCodeInput"  name = "channelCodeInput" class="input_text" readonly="readonly" style=" background-color: #ccc;width: 250px"></td>
					                </tr>
					                <tr>  
					                  <td width="30%" style="text-align:right;border-right:0px;">合作伙伴名称：&nbsp;</td>
					                  <td width="70%" style="text-align:left"><input id="channelNameInput"  name = "channelNameInput"  type="text" class="input_text" readonly="readonly" style=" background-color: #ccc;width: 250px"></td>
					                </tr>
					                <tr>  
					                  <td width="30%" style="text-align:right;border-right:0px;">合作伙伴渠道分类：&nbsp;</td>
					                  <td width="70%" style="text-align:left">
					                  		<select id="channelClassification" name = "channelClassification">
												<c:forEach var="channelClassificationList" items="${channelClassification}">
								            		<option value="${channelClassificationList.code}" title="${channelClassificationList.codeName}">${channelClassificationList.codeName}</option>
								        		</c:forEach>		
											</select>
					                  </td>
					                </tr>
								</tbody>
							</table>
						</td>
					</tr>
				</tbody>
			</table>
			<div align="center">
			   <input class="input_button_3" name="" type="button" onclick="saveOrUpdateClassification()" value="保存"/>&nbsp;&nbsp;
	           <input class="input_button_3" name="" type="button" onclick="closeSaveOrUpdateDiv()" value="取消"/>
			</div>
	</div>
</body>
</html>
